home *** CD-ROM | disk | FTP | other *** search
/ Amiga News 96 / Amiga News 96.iso / amig_ad_os / avm / avminstall / rexx / recordconversation.avm < prev    next >
Text File  |  1977-12-31  |  11KB  |  455 lines

  1. /* TITLE: avm:rexx/recordconversation.avm */
  2. /* we want results! Otherwise, we wouldn't get anything from RESULT */
  3. options results
  4.  
  5. /* Need to make sure that stdtail.avm is also included */
  6. signal on halt
  7. signal on novalue
  8. signal on syntax
  9. signal on break_c
  10.  
  11. /* needed for some of the functions we use */
  12. call addlib("rexxsupport.library", 0, -30, 0)
  13.  
  14. /* a higher than normal priority since calls are important to us :) */
  15. call pragma('priority', 1)
  16.  
  17. /* ensure that commands are directed to the correct server */
  18. parse arg servername .
  19. address value servername
  20.  
  21.  
  22. /* Initialize log */
  23.  
  24. parse arg servername faxscript datascript distinctivering 'CID$' acidname '$' acidnumber '$'
  25. call setclip(address() || 'FAXSCRIPT', faxscript)
  26. call setclip(address() || 'DATASCRIPT', datascript)
  27. call setclip(address() || 'CIDNAME', acidname)
  28. call setclip(address() || 'CIDNUMBER', acidnumber)
  29.  
  30. handle = makeUniqueFile()
  31. call initLogEntry()
  32. call time('r')
  33.  
  34. 'recordvoice' '500' '-1' '-1' voiceFile('manual', handle)
  35. a_=rc
  36. if 0 then nop
  37.  
  38. /* Save log entry */
  39.  
  40. log.filename = handle
  41. log.length = trunc(time('e'))
  42. log.comment = ''
  43. log.type = 'voice'; log.origMailbox = 'manual'
  44. call saveLogEntry('manual', handle)
  45.  
  46. /* TITLE: avm:rexx/simplestdtail.avm */
  47. /* This is the standard tail */
  48. exit
  49.  
  50. exit
  51.  
  52. mailboxDir: procedure
  53.     parse arg mailbox
  54.  
  55.     return 'avmmbox:' || mailbox || '/'
  56.  
  57. logFile: procedure
  58.     parse arg mailbox, magiccookie
  59.  
  60.     return 'avmmbox:' || mailbox || '/logs/' || magiccookie
  61.  
  62. voiceFile: procedure
  63.     parse arg mailbox, magiccookie
  64.  
  65.         if (verify(magiccookie, '/:', 'M') = 0) then
  66.           return 'avmmbox:' || mailbox || '/voices/' || magiccookie
  67.         else
  68.           return magiccookie
  69.  
  70. makeUniqueFile: procedure
  71.     if arg() ~= 0 then do
  72.         rc = "makeUniqueFile: bad args"
  73.         signal error
  74.     end
  75.     return address() || '.' || date('i') || '.' || time('s') || '.' || random(1, 999, time('s'))
  76.  
  77. convertToDate: procedure
  78.     if arg() ~= 1 then do
  79.         rc = "convertToDate: bad args"
  80.         signal error
  81.     end
  82.     parse arg timeInC
  83.  
  84.     actualTime = (timeInC - (2922)*86400) // (86400)
  85.     actualDate = (timeInC - actualTime - 2922*86400) % 86400
  86.  
  87.     return actualDate /* returning it in 'internal' format */
  88.  
  89. convertToTime: procedure
  90.     if arg() ~= 1 then do
  91.         rc = "convertToTime: bad args"
  92.         signal error
  93.     end
  94.     parse arg timeInC
  95.     
  96.     actualTime = (timeInC - (2922)*86400) // (86400)
  97.  
  98.     return actualTime
  99.  
  100. cTime: procedure
  101.     /* 2922 = 8*365 + 2 */
  102.     /* 86400 = 24*60*60 */
  103.     return (date('i')+2922)*86400 + time('s')
  104.  
  105. /* this returns a handle that you must use after initializing log. */
  106. initLogEntry: procedure expose log.
  107.     if arg() ~= 0 then do
  108.         rc = "initLogEntry: bad args"
  109.         signal error
  110.     end
  111.     
  112.     drop log.
  113.         log. = ''
  114.  
  115.         acidname = getclip(address() || 'CIDNAME')
  116.         acidnumber = getclip(address() || 'CIDNUMBER')
  117.  
  118.     /* 2922 = 8*365 + 2 */
  119.     /* 86400 = 24*60*60 */
  120.     log.time = (date('i')+2922)*86400 + time('s')
  121.     log.cidname = acidname
  122.     log.cidnumber = acidnumber
  123.  
  124.     return
  125.  
  126. loadLogEntry: procedure expose log.
  127.     if arg() ~= 2 then do
  128.         rc = "loadLogEntry: bad args"
  129.         signal error
  130.     end
  131.     parse arg mailbox, handle
  132.  
  133.         drop log.
  134.         log. = ''
  135.  
  136.     if ~exists(mailboxDir(mailbox)) then do
  137.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  138.         return
  139.     end
  140.  
  141.     opened = open(handle, logFile(mailbox, handle), 'r')
  142.         if opened then do
  143.         call showDebugger('Loading entry' logFile(mailbox, handle))
  144.         do while ~eof(handle)
  145.             line = readln(handle)
  146.             parse upper var line variable '=' value
  147.             log.variable = value
  148.         end
  149.         call close(handle)
  150.     end; else call showDebugger('Could not load' logFile(mailbox, handle))
  151.     return
  152.  
  153. /* pass a handle here */
  154. saveLogEntry: procedure expose log.
  155.     if arg() ~= 2 then do
  156.         rc = "saveLogEntry: bad args"
  157.         signal error
  158.     end
  159.     parse arg mailbox, handle
  160.  
  161.     if ~exists(mailboxDir(mailbox)) then do
  162.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  163.         return
  164.     end
  165.  
  166.     opened = open(handle, logFile(mailbox, handle), 'w')
  167.  
  168.     if opened then do
  169.         call showDebugger('Saving entry' logFile(mailbox, handle))
  170.         call writeln(handle, 'TYPE=' || log.type)
  171.         call writeln(handle, 'TIME=' || log.time)
  172.         call writeln(handle, 'LENGTH=' || log.length)
  173.  
  174.         call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
  175.  
  176.         call writeln(handle, 'CIDNAME=' || log.cidname)
  177.         call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
  178.  
  179.         call writeln(handle, 'COMMENT=' || log.comment)
  180.  
  181.         call writeln(handle, 'FILENAME=' || log.filename)
  182.         call writeln(handle, 'ALTFILENAME=' || log.altfilename)
  183.  
  184.         call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
  185.         call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
  186.         call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
  187.  
  188.         call writeln(handle, 'RETURNRETRY=' || log.returnretry)
  189.         call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
  190.  
  191.         call close(handle)
  192.         address rexx 'broadcast' 'addtomailbox' mailbox handle
  193.     end; else call showDebugger('Could not save' logFile(mailbox, handle))
  194.  
  195.     return
  196.  
  197. /* pass a handle here */
  198. updateLogEntry: procedure expose log.
  199.     if arg() ~= 2 then do
  200.         rc = "updateLogEntry: bad args"
  201.         signal error
  202.     end
  203.     parse arg mailbox, handle
  204.  
  205.     if ~exists(mailboxDir(mailbox)) then do
  206.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  207.         return
  208.     end
  209.  
  210.     if ~exists(logFile(mailbox, handle)) then do
  211.         call showDebugger('Unable to update non-existent' logFile(mailbox, handle))
  212.         return
  213.     end
  214.     opened = open(handle, logFile(mailbox, handle), 'w')
  215.  
  216.     if opened then do
  217.         call showDebugger('Updating entry' logFile(mailbox, handle))
  218.         call writeln(handle, 'TYPE=' || log.type)
  219.         call writeln(handle, 'TIME=' || log.time)
  220.         call writeln(handle, 'LENGTH=' || log.length)
  221.  
  222.         call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
  223.  
  224.         call writeln(handle, 'CIDNAME=' || log.cidname)
  225.         call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
  226.  
  227.         call writeln(handle, 'COMMENT=' || log.comment)
  228.  
  229.         call writeln(handle, 'FILENAME=' || log.filename)
  230.         call writeln(handle, 'ALTFILENAME=' || log.altfilename)
  231.  
  232.         call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
  233.         call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
  234.         call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
  235.  
  236.         call writeln(handle, 'RETURNRETRY=' || log.returnretry)
  237.         call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
  238.  
  239.         call close(handle)
  240.         address rexx 'broadcast' 'refreshmailboxentry' mailbox handle
  241.     end; else call showDebugger('Could not update' logFile(mailbox, handle))
  242.  
  243.     return
  244.  
  245.  
  246.  
  247. showDebugger: procedure
  248.     if arg() ~= 1 then do
  249.         say "showDebugger: ERROR"
  250.         exit 20
  251.     end
  252.  
  253.     parse arg debuggerInfo
  254.     
  255.     firstLine = sourceline(1)
  256.     parse var firstLine '/*' 'TITLE:' title '*/'
  257.     if showlist('p', 'AVMUSERINTERFACE') then
  258.         address 'AVMUSERINTERFACE' 'addlog' title ':' debuggerInfo
  259.     else
  260.         say title ':' debuggerInfo
  261.  
  262.     return 
  263.  
  264. /*-----------------------------------------------------------------------*/
  265. /*                         signal processing                             */
  266.  
  267. arexxerror:
  268. error:
  269.     call showDebugger("Error" rc "at line" sigl)
  270.     exit 20
  271.  
  272. break_c:
  273. halt:
  274.     call showDebugger("Halt/Break_C at line" sigl)
  275.     exit 20
  276.  
  277. novalue:
  278.     call showDebugger("No value at line" sigl)
  279.     exit 20
  280.  
  281. syntax:
  282.     call showDebugger("Syntax error" rc "at line" sigl)
  283.     exit 20
  284.  
  285. /* TITLE: avm:rexx/stdplayvoice.avm */
  286. stdPlayXX:
  287. procedure
  288. parse arg ret
  289.  
  290. rs.normal = 0
  291. rs.keydetected = 1
  292. rs.quietdetected = 2
  293. rs.silencedetected = 3
  294. rs.faxdetected = 4
  295. rs.datadetected = 5
  296. rs.busydetected = 8
  297. rs.timedout = 10
  298. rs.signaldetected = 12
  299. rs.overflow = 14
  300. rs.error = 16
  301. /* CB 0000 */
  302.  
  303. select
  304.   when ret=rs.faxdetected then signal stdfax
  305.   when ret=rs.datadetected then signal stddata
  306.   when ret=rs.busydetected then signal stdbusy
  307.   when ret=rs.signaldetected then signal stdabort
  308.   when ret=rs.overflow then signal stderror
  309.   when ret=rs.error then signal stderror
  310.   otherwise nop
  311. end
  312. return
  313.  
  314.  
  315. aapresentmenu:
  316. /* TITLE: avm:rexx/presentmenu.avm */
  317. procedure expose pmRetries pmTimesAround
  318. parse arg filename, valid, retries
  319. timesaround = retries
  320. pmTimesAround = timesaround
  321. pmRetries = retries
  322.  
  323. rs.normal = 0
  324. rs.keydetected = 1
  325. rs.quietdetected = 2
  326. rs.silencedetected = 3
  327. rs.faxdetected = 4
  328. rs.datadetected = 5
  329. rs.busydetected = 8
  330. rs.timedout = 10
  331. rs.signaldetected = 12
  332. rs.overflow = 14
  333. rs.error = 16
  334. /* CB 0000 */
  335.  
  336. aapresentmenuloop:
  337. 'playvoice' filename
  338. a_=rc
  339. if 0 then nop
  340. else if a_=4 then do;return rs.faxdetected;end
  341. else if a_=5 then do;return rs.datadetected;end
  342. else if a_=8 then do;return rs.busydetected;end
  343. else if a_=12 then do;return rs.signaldetected;end
  344. else if a_=14 then do;return rs.error;end
  345. else if a_=16 then do;return rs.error;end
  346.  
  347. 'readnkeys' '1' '5'
  348. a_=rc
  349. if a_=0 then value=result
  350. if 0 then nop
  351. else if a_=0 then signal aapresentmenuvalue
  352. else if a_=4 then do;return rs.faxdetected;end
  353. else if a_=5 then do;return rs.datadetected;end
  354. else if a_=8 then do;return rs.busydetected;end
  355. else if a_=10 then signal aapresentmenutimeout
  356. else if a_=12 then do;return rs.signaldetected;end
  357. else if a_=14 then do;return rs.error;end
  358. else if a_=16 then do;return rs.error;end
  359. return rs.error
  360.  
  361. aapresentmenutimeout:
  362. 'flushphonebuffer'
  363.  
  364. 'playvoice' 'avm:voices/TimedOut'
  365. a_=rc
  366. if 0 then nop
  367. else if a_=4 then do;return rs.faxdetected;end
  368. else if a_=5 then do;return rs.datadetected;end
  369. else if a_=8 then do;return rs.busydetected;end
  370. else if a_=12 then do;return rs.signaldetected;end
  371. else if a_=14 then do;return rs.error;end
  372. else if a_=16 then do;return rs.error;end
  373.  
  374. timesaround = timesaround - 1; pmTimesAround = timesaround
  375. if timesaround <= 0 then return rs.timedout
  376. signal aapresentmenuloop
  377.  
  378. aapresentmenuvalue:
  379. if pos(value, valid) = 0 then signal aainvalid
  380. return '=' || value
  381.  
  382. aainvalid:
  383. 'flushphonebuffer'
  384.  
  385. 'playvoice' 'avm:voices/BadChoice'
  386. a_=rc
  387. if 0 then nop
  388. else if a_=4 then do;return rs.faxdetected;end
  389. else if a_=5 then do;return rs.datadetected;end
  390. else if a_=8 then do;return rs.busydetected;end
  391. else if a_=12 then do;return rs.signaldetected;end
  392. else if a_=14 then do;return rs.error;end
  393. else if a_=16 then do;return rs.error;end
  394.  
  395. timesaround = timesaround - 1; pmTimesAround = timesaround
  396. if timesaround <= 0 then return rs.timedout
  397. signal aapresentmenuloop
  398.  
  399.  
  400. stdabort:
  401. exit
  402.  
  403. stdbusy:
  404. exit
  405.  
  406. stderror:
  407. exit
  408.  
  409. stdtimedout:
  410. exit
  411.  
  412. stdfaxinstruct:
  413. 'playvoice' 'avm:voices/FaxStarting'
  414. a_=rc
  415. if 0 then nop
  416. else if a_=1 then do;call checkifabort;end
  417. else if a_=8 then signal stdbusy
  418. else if a_=12 then signal stdabort
  419.  
  420. stdfax:
  421. faxscript = getclip(address() || 'FAXSCRIPT')
  422. if faxscript = '' then faxscript = 'handlefax'
  423. if symbol('mailbox') = 'VAR' then address rexx faxscript address() mailbox
  424. else address rexx faxscript address() 'anonymous'
  425. exit
  426.  
  427. stddatainstruct:
  428. 'playvoice' 'avm:voices/DataStarting'
  429. a_=rc
  430. if 0 then nop
  431. else if a_=1 then do;call checkifabort;end
  432. else if a_=8 then signal stdbusy
  433. else if a_=12 then signal stdabort
  434.  
  435. stddata:
  436. datascript = getclip(address() || 'DATASCRIPT')
  437. if datascript = '' then datascript = 'handledata'
  438. if symbol('mailbox') = 'VAR' then address rexx datascript address() mailbox
  439. else address rexx datascript address()
  440. exit
  441.  
  442. checkifabort:
  443. 'readnkeys' '1' '3'
  444. a_=rc
  445. if a_=0 then value=result
  446. if 0 then nop
  447. else if a_=0 then do;if value = '*' then signal stdabort;end
  448. else if a_=8 then signal stdbusy
  449. else if a_=12 then signal stdabort
  450. else if a_=14 then signal stderror
  451. else if a_=16 then signal stderror
  452. return
  453.  
  454.  
  455.